<template>
	<view class="pages">
		<view class="card m-b-30" v-for="(item,index) in list" :key="index">
			<view class="f-36 f-bold t-c m-b-30">{{item.title}}</view>
			<text class="">{{item.content}}</text>
			<view class="t-r col-6 m-t-30">{{item.time}}</view>
		</view>
		<u-loadmore :status="status" loadingText="正在加载中,上下滑动重新加载" />
		<u-back-top :scrollTop="scrollTop" bottom="100" :customStyle="{'background-color':'#2979ff'}" :iconStyle="{
				'fontSize': '40rpx',
				'color':'#FFF' }"></u-back-top>
	</view>
</template>

<script>
	import {
		getNoticeListDetail
	} from '@/api/list.js'
	export default {
		onLoad() {
			this.getNoticeList()
		},
		onReachBottom() {
			this.getNoticeList()
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		data() {
			return {
				status: 'nomore',
				scrollTop: 0,
				list: [],
				page: 1
			}
		},
		methods: {
			async getNoticeList() {
				this.status = 'loading'
				const res = await getNoticeListDetail({
					page: this.page,
					limit: 8,
				})
				this.status = 'nomore'
				if (res.code === 200) {
					if (res.data.length === 0) return
					this.page++
					this.list.push(...res.data)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pages {
		padding: 30rpx;
	}

	.card {
		padding: 30rpx;
		border-radius: 20rpx;
		background-color: #fff;
	}
</style>
